﻿/*
 * Erstellt mit SharpDevelop.
 * Benutzer: Kai Patrick
 * Datum: 05.04.2008
 * Zeit: 15:19
 * 
 * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
 */

using System;
using System.Collections.Generic;

namespace Gamadus.Engine
{
	/// <summary>
	/// Description of VariableList.
	/// </summary>
	public class InstanceVarList
	{
		ObjectSuper parent;
		public InstanceVarList(ObjectSuper parent)
		{
			this.parent = parent;
		}
		
		Dictionary<string, GmlVar> vars = new Dictionary<string, GmlVar>();
		public GmlVar this[string key]
		{
		    get
		    {
		    	switch(key)
		    	{
					case "x": return parent.x;
					case "y": return parent.y;
					case "persistent": return parent.persistent;
					case "depth": return parent.depth;
					case "visible": return parent.visible;
					case "hspeed": return parent.hspeed;
					case "vspeed": return parent.vspeed;
		    		default: return vars[key];
		    	}
		    }
		    set
		    {
		    	switch(key)
		    	{
					case "x": parent.x = value; break;
					case "y": parent.y = value; break;
					case "persistent": parent.persistent = value; break;
					case "depth": parent.depth = value; break;
					case "visible": parent.visible = value; break;
					case "hspeed": parent.hspeed = value; break;
					case "vspeed": parent.vspeed = value; break;
		    		default: vars[key] = value; break;
		    	}
		    }
		}
	}
	
	public class ObjectVarList
	{
		Gamadus.Engine.Object parent;
		public ObjectVarList(Gamadus.Engine.Object parent)
		{
			this.parent = parent;
		}
		
		public GmlVar this[string key]
		{
		    get
		    {
		    	if(parent.FirstInstance != null)
		    		return parent.FirstInstance.Variable[key];

		    	throw new ArgumentNullException("There is no instance of this object");
		    }
		    set
		    {
		    	foreach(ObjectSuper inst in parent.Instances)
		    	{
		    		inst.Variable[key] = value;
		    	}
	
		    }
		}
	}
}
